Add a bounding box test that will avoid getting the individual cell boxes
authorMatthias Clasen <mclasen@redhat.com>
Mon, 10 Sep 2007 00:43:58 +0000 (00:43 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 10 Sep 2007 00:43:58 +0000 (00:43 +0000)
2007-09-09  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkiconview.c (gtk_icon_view_item_hit_test): Add a
        bounding box test that will avoid getting the individual cell
        boxes if they haven't been calculated yet.  (#404541)

svn path=/trunk/; revision=18775

ChangeLog
gtk/gtkiconview.c

index c28011c4ef50daccf2c82dd4c24106e817c8c26b..2fdfdac2deaae43496ea36d91498b0c525fa949f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-09  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkiconview.c (gtk_icon_view_item_hit_test): Add a 
+       bounding box test that will avoid getting the individual cell
+       boxes if they haven't been calculated yet.  (#404541)
+
 2007-09-09  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c:
index 7d9fcf4558a263c22888904da9f4e4d5239d63ac..f5e14e506cf2d610f75c01df19e76719f8156ee2 100644 (file)
@@ -2284,6 +2284,10 @@ gtk_icon_view_item_hit_test (GtkIconView      *icon_view,
   GList *l;
   GdkRectangle box;
  
+  if (MIN (x + width, item->x + item->width) - MAX (x, item->x) <= 0 ||
+      MIN (y + height, item->y + item->height) - MAX (y, item->y) <= 0)
+    return FALSE;
+
   for (l = icon_view->priv->cell_list; l; l = l->next)
     {
       GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data;
@@ -2705,6 +2709,8 @@ gtk_icon_view_get_cell_area (GtkIconView         *icon_view,
                             GtkIconViewCellInfo *info,
                             GdkRectangle        *cell_area)
 {
+  g_return_if_fail (info->position < item->n_cells);
+
   if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       cell_area->x = item->box[info->position].x - item->before[info->position];
@@ -2729,6 +2735,8 @@ gtk_icon_view_get_cell_box (GtkIconView         *icon_view,
                            GtkIconViewCellInfo *info,
                            GdkRectangle        *box)
 {
+  g_return_if_fail (info->position < item->n_cells);
+
   *box = item->box[info->position];
 }